package com.ontheroad.mysql.banner.service;

import cn.modoumama.service.base.impl.BaseServiceImpl;
import com.ontheroad.banner.model.BannerModel;
import com.ontheroad.banner.service.BannerService;
import com.ontheroad.mysql.banner.mapper.BannerMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by kedong on 2017/10/12 0012.
 */
@Service
@Transactional
public class BannerServiceImpl extends BaseServiceImpl<BannerModel, Integer> implements BannerService {

    private Logger log = LoggerFactory.getLogger(getClass());

    @Autowired
    private BannerMapper mapper;

    @Autowired
    public void setMapper(BannerMapper mapper) {
        setGenericMapper(mapper);
    }

    @Override
    public BannerModel findFirstPublishBanner() {
        return mapper.findFirstPublishBanner();
    }

    @Override
    public Integer getPublishCount() {
        return mapper.getPublishCount();
    }

    @Override
    public BannerModel save(BannerModel banner) {
        mapper.insertModel(banner);
        return banner;
    }

}
